package com.love_weinuo.util.dialog;

import android.content.Context;
import android.databinding.DataBindingUtil;
import android.text.TextUtils;
import android.view.LayoutInflater;
import android.view.View;

import com.love_weinuo.R;
import com.love_weinuo.databinding.DialogInputInviteBinding;
import com.love_weinuo.util.LogUtil;
import com.love_weinuo.util.ToastUtil;
import com.love_weinuo.util.listener.OnBHClickListener;
import com.love_weinuo.util.listener.OnLandNameInputListener;

/**
 * Created by Administrator on 2019/3/24.
 */

public class InputInviteDialog extends BaseDialog {

    Context context;
    DialogInputInviteBinding binding;
    OnBHClickListener onBHClickListener;
    OnLandNameInputListener listener;
    String inviteCode = "";

    public InputInviteDialog(Context context) {
        super(context);
        this.context = context;
        binding = DataBindingUtil.inflate(LayoutInflater.from(context), R.layout.dialog_input_invite, null, false);
        binding.setDialog(this);
        setContentView(binding.getRoot());
    }

    public void setOnBHClickListener(OnBHClickListener onBHClickListener) {
        this.onBHClickListener = onBHClickListener;
    }

    public void setOnLandNameInputListener(OnLandNameInputListener listener){
        this.listener = listener;
    }

    public void noPoint(View view) {
        LogUtil.e("点击跳过");
        if (onBHClickListener != null) {
            onBHClickListener.onCloseClick();
        }
        dismiss();
    }

    public void okPoint(View view) {
        LogUtil.e("点击确定");
        if (onBHClickListener != null) {
            onBHClickListener.onConfirmClick();
        }
        inviteCode = binding.etModuleInviteCode.getText().toString().trim();
        if (TextUtils.isEmpty(inviteCode)) {
            ToastUtil.showToast("请输入邀请码");
            return;
        }else{
            if (listener != null) {
                listener.setOnLandNameInputListener(inviteCode);
            }
        }
        dismiss();
    }
}

